/*    */ package com.zimbra.qa.unittest.prov.soap;
/*    */ 
/*    */ import com.google.common.collect.Sets;
/*    */ import com.zimbra.common.soap.SoapTransport;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.GranteeType;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.User;
/*    */ import com.zimbra.cs.account.accesscontrol.UserRight;
/*    */ import com.zimbra.qa.unittest.prov.Verify;
/*    */ import com.zimbra.soap.account.message.GetInfoRequest;
/*    */ import com.zimbra.soap.account.message.GetInfoResponse;
/*    */ import com.zimbra.soap.account.type.DiscoverRightsInfo;
/*    */ import com.zimbra.soap.account.type.DiscoverRightsTarget;
/*    */ import com.zimbra.soap.admin.type.GranteeSelector.GranteeBy;
/*    */ import com.zimbra.soap.type.TargetBy;
/*    */ import java.util.List;
/*    */ import java.util.Set;
/*    */ import org.junit.AfterClass;
/*    */ import org.junit.BeforeClass;
/*    */ import org.junit.Test;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class TestGetInfo
/*    */   extends SoapTest
/*    */ {
/*    */   private static SoapProvTestUtil provUtil;
/*    */   private static Provisioning prov;
/*    */   private static Domain domain;
/*    */   
/*    */   @BeforeClass
/*    */   public static void init()
/*    */     throws Exception
/*    */   {
/* 50 */     provUtil = new SoapProvTestUtil();
/* 51 */     prov = provUtil.getProv();
/* 52 */     domain = provUtil.createDomain(baseDomainName());
/*    */   }
/*    */   
/*    */   @AfterClass
/*    */   public static void cleanup() throws Exception {
/* 57 */     Cleanup.deleteAll(new String[] { baseDomainName() });
/*    */   }
/*    */   
/*    */   @Test
/*    */   public void discoverRights() throws Exception {
/* 62 */     Account acct = provUtil.createAccount(genAcctNameLocalPart(), domain);
/* 63 */     Group group = provUtil.createGroup(genGroupNameLocalPart(), domain, false);
/*    */     
/* 65 */     prov.grantRight(com.zimbra.cs.account.accesscontrol.TargetType.domain.getCode(), TargetBy.name, domain.getName(), GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, Rights.User.R_createDistList.getName(), null);
/*    */     
/*    */ 
/*    */ 
/* 69 */     prov.grantRight(com.zimbra.cs.account.accesscontrol.TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, Rights.User.R_sendToDistList.getName(), null);
/*    */     
/*    */ 
/*    */ 
/* 73 */     SoapTransport transport = authUser(acct.getName());
/*    */     
/* 75 */     GetInfoRequest req = new GetInfoRequest();
/* 76 */     req.addRight(Rights.User.R_createDistList.getName());
/* 77 */     req.addRight(Rights.User.R_sendToDistList.getName());
/* 78 */     GetInfoResponse resp = (GetInfoResponse)invokeJaxb(transport, req);
/*    */     
/* 80 */     List<DiscoverRightsInfo> rightsInfo = resp.getDiscoveredRights();
/*    */     
/* 82 */     Set<String> result = Sets.newHashSet();
/*    */     
/* 84 */     for (DiscoverRightsInfo rightInfo : rightsInfo) {
/* 85 */       right = rightInfo.getRight();
/* 86 */       List<DiscoverRightsTarget> targets = rightInfo.getTargets();
/*    */       
/* 88 */       for (DiscoverRightsTarget target : targets) {
/* 89 */         String id = target.getId();
/* 90 */         String name = target.getName();
/* 91 */         String type = target.getType().toString();
/*    */         
/* 93 */         result.add(Verify.makeResultStr(new Object[] { right, id, name, type }));
/*    */       }
/*    */     }
/*    */     String right;
/* 97 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { Rights.User.R_createDistList.getName(), domain.getId(), domain.getName(), com.zimbra.cs.account.accesscontrol.TargetType.domain.getCode() }), Verify.makeResultStr(new Object[] { Rights.User.R_sendToDistList.getName(), group.getId(), group.getName(), com.zimbra.cs.account.accesscontrol.TargetType.dl.getCode() }) }), result);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/soap/TestGetInfo.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */